Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
glob-stream
Advanced tools
The glob-stream npm package allows for reading file paths from a globbing pattern. It is a wrapper around node-glob and vinyl-fs to stream the file objects that match the glob patterns. This package is particularly useful in build processes and file manipulation scripts where matching files based on patterns is required.
Reading files using glob patterns
This feature allows you to read files that match a specific pattern. In the code sample, all JavaScript files under the 'src' directory and its subdirectories are matched and their paths are logged.
const globStream = require('glob-stream');
const stream = globStream('./src/**/*.js');
stream.on('data', function(file) {
console.log(file.path);
});
Combining multiple glob patterns
glob-stream supports combining multiple patterns, including exclusion patterns. In this example, all JavaScript files under 'src' except those in the 'vendor' subdirectory are matched.
const globStream = require('glob-stream');
const stream = globStream(['./src/**/*.js', '!./src/vendor/**']);
stream.on('data', function(file) {
console.log(file.path);
});
fast-glob is an alternative to glob-stream that provides a similar functionality of matching files based on glob patterns. It is known for its performance and offers a promise-based API, making it a good choice for modern asynchronous workflows. Unlike glob-stream, fast-glob does not return a stream of file objects but rather a promise that resolves with an array of matching paths.
node-glob is the underlying library used by glob-stream for matching files based on patterns. While glob-stream provides a stream interface for handling the matched files, node-glob itself focuses on the globbing functionality and returns an array of matched file paths. It is a more basic option for those who do not need the streaming capabilities offered by glob-stream.
A wrapper around node-glob to make it streamy.
var gs = require('glob-stream');
var stream = gs.create('./files/**/*.coffee', { /* options */ });
stream.on('data', function(file){
// file has path, base, and cwd attrs
});
You can pass any combination of globs. One caveat is that you can not only pass a glob negation, you must give it at least one positive glob so it knows where to start. All given must match for the file to be returned.
Returns a stream for multiple globs or filters.
Returns a stream for a single glob or filter.
process.cwd()
false
false
This argument is passed directly to node-glob so check there for more options
var stream = gs.create(['./**/*.js', '!./node_modules/**/*']);
Globs are executed in order, so negations should follow positive globs. For example:
gulp.src(['!b*.js', '*.js'])
would not exclude any files, but this would
gulp.src(['*.js', '!b*.js'])
glob
wrapper with support for multiple patterns.MIT
FAQs
Readable streamx interface over anymatch.
The npm package glob-stream receives a total of 1,263,118 weekly downloads. As such, glob-stream popularity was classified as popular.
We found that glob-stream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.